#include "message.h"
#include <assert.h>

int main(int argc, char *argv[])
{
	using namespace sobriety;
	char test_keepalive[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
				0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x13, 0x04};
	char test_open[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
				0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
				0x00, 0x1d, 0x01, 0x04, 0xfd, 0xe9, 0x00, 0x3c,
				0xff, 0xff, 0xff, 0xff, 0x00};
	char test_notification[] = { 	  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
					  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
					  0x00, 0x27, 0x03, 0x04, 0x00, 0x59, 0x4f, 0x55,
					  0x20, 0x41, 0x52, 0x45, 0x20, 0x41, 0x20, 0x53,
					  0x54, 0x4f, 0x4f, 0x50, 0x49, 0x44, 0x21 };



	void *real_keepalive = NULL;
	void *real_open = NULL;
	void *real_notification = NULL;
	int length = 0;

	struct bgp_settings settings;
	settings.version = 4;
	settings.as = 65001;
	settings.hold = 60;
	settings.id = 4294967295;

	// test keepalives messages
	Message test1(kKeepalive, &settings);
	real_keepalive = test1.getData();
	length = test1.getLength();
	assert(length == 19);
	assert((memcmp(test_keepalive, real_keepalive, 19) == 0));
	printf("Test 1 (keepalive message validity): PASSED\n");

	// test open messages
	Message test2(kOpen, &settings);
	real_open = test2.getData();
	length = test2.getLength();
	assert(length == 29);
	assert((memcmp(test_open, real_open, 29) == 0));
	printf("Test 2 (open message validity): PASSED\n");
	
	// test notification messages
	Message test3(kNotification, &settings);
	real_notification = test3.getData();
	length = test3.getLength();
	assert(length == 39);
	assert((memcmp(test_notification, real_notification, 39) == 0));
	printf("Test 3 (notification message validity): PASSED\n");

	//Message test3(kNotification, &settings);
	//data = test3.getData();
	//length = test3.getLength();

	return 0;
}
